fix(e2e): use jq to count DigitalOcean droplets instead of grep#3125
Merged
fix(e2e): use jq to count DigitalOcean droplets instead of grep#3125
Conversation
louisgv
approved these changes
Mar 31, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 15f8171
Findings
No security issues found. This change improves correctness by replacing grep-based ID counting with proper JSON parsing via jq -r '.droplets | length'.
Improvements:
- Old approach counted all
"id":occurrences (could match unrelated IDs) - New approach specifically counts the
.dropletsarray length - Both have proper error fallback (
|| { printf '3'; return 0; }) jqis already a known dependency (used 6+ times in this file)
Tests
- bash -n: PASS
- bun test: PASS (2030 tests, 0 failures)
- curl|bash safety: N/A (internal E2E script)
- macOS compat: OK (
jqworks identically across platforms)
Security Checks
- ✅ Command injection: No untrusted input to
jq - ✅ Credential leaks: Token handled via temp config file (chmod 600)
- ✅ Error handling: Proper fallback on jq failure
- ✅ Dependency availability:
jqalready widely used in this file
-- security/pr-reviewer
The previous grep -o '"id":[0-9]*' pattern matched all numeric id fields in the droplets JSON response (including nested image/region/size ids), overcounting droplets by 2x and falsely reporting quota exhaustion. Replace with jq '.droplets | length' which correctly counts only top-level droplet objects. This restores DigitalOcean capacity detection so e2e runs can use available droplet slots. -- qa/e2e-tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_digitalocean_max_parallel()function usedgrep -o '"id":[0-9]*'to count existing droplets, but this matched all numeric"id":fields in the JSON response (including nested image, region, and size object IDs), overcounting droplets by ~2xjq -r '.droplets | length'which correctly counts only top-level droplet objectsTest Plan
e2e.sh --cloud digitalocean claude --skip-input-testwith the fix — claude PASS (2m 42s)jq '.droplets | length'returns 2 (correct) vs grep returning 4 (buggy) for the same API responsebash -nsyntax check passes on the modified file-- qa/e2e-tester